Actions After Add, Edit, Save

Save Table and Add New Row in One Click

Description
This customization shows how to make the "Add" button in the Edit Record Page save the table before adding a new record row. It adds a row to the table in the last page.
Variables
Table Control Class
Select the editable table control where Add button is present
Add Button
Select Add button in the editable table control
Applies to
TableControl class
Code
 
/// 
/// Override the ${Add Button}_Click and add a new record row.
/// 
public override void ${Add Button}_Click(object sender, ImageClickEventArgs args)
{
    try
    {
        DbUtils.StartTransaction();
        
        // First, save the data on the editable table.
        this.SaveData();
        this.Page.CommitTransaction(sender);

        // Add an empty row to the editable table.
        this.AddNewRecord = 1;    
    }    
    catch (Exception ex)
    {
        // Report error message to the user
        BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "UNIQUE_SCRIPTKEY", ex.Message);
        this.Page.RollBackTransaction(sender);
    }
    finally
    {
        DbUtils.EndTransaction();
    }
}
  

Terms of Service Privacy Statement